'use strict';

/**
 * @ngdoc overview
 * @name angularApp
 * @description # angularApp
 * 
 * Main module of the application.
 */
var app = angular.module('angularApp', ['ngRoute', 'ngResource', 'angularUtils.directives.dirPagination',
                                        'ngTagsInput', 'angular-loading-bar']);

app.config(['$httpProvider', function($httpProvider) {
	$httpProvider.defaults.withCredentials = true;
	$httpProvider.interceptors.push(function($q, $location) {
		return {
			'responseError' : function(rejection) {
				if (rejection.status === 401) {
					$location.url("/login");
				}
				return $q.reject(rejection);
			}
		};
	});
}]);

app.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/', {
		templateUrl : 'views/home.html'
	}).when('/:page', {
		templateUrl : function($routeParams) {
			return 'views/' + $routeParams.page + '.html';
		}
	}).otherwise({
		redirectTo : '/'
	});
}]);

app.constant('serverUrl', '');
